<?php
include_once "../common.php";
/***********
 * <meta name="author" content="name">
 * <meta name="keywords" content="php documentation">
 * <meta name="DESCRIPTION" content="a php manual">
 * <meta name="geo.position" content="49.33;-86.59">
 * </head> <!-- parsing stops here -->
 */

if(isset($_GET['website']))
{
	$_GET['website'] = makeWebsiteFriendly($_GET['website']);
	
	// add file...
	$query = "	SELECT 
					ID, Metatag
				FROM Webshops 
				WHERE Website = '".str_replace("'","",$_GET['website'])."'
					AND CustomerID = '".str_replace("'","",$_SESSION['login']['ID'])."'";
	
	if($result = $_MySQL->runQuery($query))
	{
		if(mysql_num_rows($result) > 0)
		{
			while($row = mysql_fetch_assoc($result))
			{
				if(url_exists($_GET['website'].'/'.$row['Metatag'].'.html'))
				{
					// valid url....
					$query = "UPDATE Webshops SET Status = '3' WHERE ID = '".str_replace("'","",$row['ID'])."' LIMIT 1";
					$_MySQL->runQuery($query);
					echo "succes";
					exit;
				}
				else
					echo "De opgegeven HTML staat niet op de site (".$_GET['website'].'/'.$row['Metatag'].'.html'.")\nERROR: 404";	
			}
		}
		else
			echo "Geen webshop gevonden";
	}
	else
		echo "Query error";
}